package xyz.xiezc.xsync.server.login;

import cn.hutool.core.lang.Assert;
import cn.hutool.extra.mail.MailUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.xiezc.xsync.server.common.Result;
import xyz.xiezc.xsync.server.dao.UserMapper;
import xyz.xiezc.xsync.server.entity.FilePatchDO;
import xyz.xiezc.xsync.server.entity.UserDO;

import javax.annotation.Resource;

/**
 * @Description 登录的控制器
 * @Author xiezc
 * @Version 1.0
 * @Date 2020/10/10 5:38 下午
 **/
@RequestMapping("/login")
@RestController
public class LoginController {

    @Resource
    UserMapper userMapper;

    @PostMapping("sign")
    public Result sign(UserDO userDO) {
        LambdaQueryWrapper<UserDO> queryWrapper = new LambdaQueryWrapper<>(UserDO.class);
        Assert.notBlank(userDO.getEmail(),"请输入登录邮箱");
        queryWrapper.eq(UserDO::getEmail, userDO.getEmail());
        userDO = userMapper.selectOne(queryWrapper);
        return Result.success(userDO);
    }

}